<template>
	<view>
		<comtarbar class="comtarbar">
			<template #center>
				<view class="title">
					<view>与我相关</view>
				</view>
			</template>
		</comtarbar>
		<view class="content">
			<template v-for="(item,index) in getComNotify">
				<view class="com_box" v-if="item.type=='like'" :key="index">
					<view class="box_top">
						<view class="user">{{item.fromName}}</view>
						<view class="text">赞了你的动态</view>
					</view>
					<view class="box_middle">
						<view class="innerbox">
							<view class="m_user"  @tap="goInfo(item.fromUser)">{{getUser.name}}:</view>
							<view class="m_text">{{item.text}}</view>
						</view>
					</view>
					<view class="box_bottom">
						<view class="date">{{ item.date | dateFormat }}</view>
						<view class="btn">
							<view class="delete_btn">
								<image src="../../../static/images/dynamic/delete.png" mode="widthFix"></image>
							</view>
							<view class="info_btn">查看详情>></view>
						</view>
					</view>
					<view class="tip">
						<image v-if="!item.unRead" src="../../../static/images/dynamic/new.png" mode="widthFix"></image>
						<image v-else src="../../../static/images/dynamic/read.png" mode="widthFix"></image>
					</view>
				</view>
				<view class="com_box" v-if="item.type=='comment'" :key="index">
					<view class="box_top">
						<view class="user" @tap="goInfo(item.fromUser)">{{item.fromName}}</view>
						<view class="text">回复</view>
						<view class="user" v-if="item.toUser!=getUser._id" @tap="goInfo(item.toUser)">{{item.toName}}</view>
						<view class="text" v-else>我</view>
						<view class="text">:</view>
					</view>
					<view class="com_conten">
						{{item.content}}
					</view>
					<view class="box_middle">
						<view class="innerbox">
							<view class="m_user">{{getUser.name}}:</view>
							<view class="m_text">{{item.text}}</view>
						</view>
					</view>
					<view class="box_bottom">
						<view class="date">{{item.date|dateFormat}}</view>
						<view class="btn">查看详情>></view>
					</view>
					<view class="tip" >
						<image v-if="!item.unRead" src="../../../static/images/dynamic/new.png" mode="widthFix"></image>
						<image v-else src="../../../static/images/dynamic/read.png" mode="widthFix"></image>
					</view>
				</view>
			</template>
			
		</view>
	</view>
</template>

<script>
	import {mapGetters} from "vuex"
	import request from '../../../api/request.js';
export default {
	data() {
		return {};
	},
	computed:{
		...mapGetters(["getComNotify","getUser"])
	},
	mounted(){
		this.updateCom()
	},
	beforeDestroy(){
		this.$store.dispatch("getComNotify")
	},
	methods:{
		// 好友详情页
		goInfo(id) {
			uni.navigateTo({
				url: "../../information/information?id="+id
			});
		},
		// 更新评论通知表
		async updateCom(){
			let res = await request({
				url: '/comment/update',
				data: {
					token: uni.getStorageSync('token')
				},
				method:"POST"
			});
		}
	},
	
};
</script>

<style lang="scss" scoped>
@import '../../../commons/css/mycss.scss';
.comtarbar {
	background: #f4f4f4;
}
.content{
	padding: 0 40rpx;
	padding-top: 120rpx;
}
/* #ifdef APP-PLUS */
	.content{
		padding-top: 180rpx;
	}
/* #endif */
.com_box{
	box-shadow: 0rpx 0rpx 12rpx 0rpx rgba(0,0,0,.4);
	padding: 20rpx;
	border-radius: 10rpx;
	margin-bottom: 40rpx;
	position: relative;
	.box_top{
		display: flex;
		font-size: 32rpx;
		padding: 0rpx 20rpx;
		.user{
			color: rgb(21, 125, 181);
		}
		.text{
			padding: 0rpx 10rpx;
			color: #555555;
		}
	}
	.com_conten{
		padding: 10rpx 20rpx 0rpx 60rpx;
		font-size: 32rpx;
	}
	.box_middle{
		display: flex;
		justify-content: center;
		align-items: center;
		margin: 20rpx 0rpx;
		.innerbox{
			width: 90%;
			border-radius: 10rpx;
			padding: 20rpx;
			background: #f3f3f3;
			font-size: 32rpx;
			.m_user{
				color: rgb(21, 125, 181);
			}
			.m_text{
				padding-left: 80rpx;
				padding-top: 10rpx;
				color: #555555;
			}
		}
	}
	.box_bottom {
		display: flex;
		font-size: 30rpx;
		justify-content: space-between;
		padding: 0rpx 20rpx;
		color: #cacaca;
		.date {
		}
		.btn {
			display: flex;
			.delete_btn{
				margin-right: 30rpx;
				width: 28rpx;
				vertical-align: bottom;
				image{
					margin-top: 6rpx;
					width: 100%;
					height: auto;
				}
			}
			.info_btn{
				vertical-align: top;
			}
		}
	}
	.tip{
		position: absolute;
		top: -10rpx;
		right: -12rpx;
		image{
			width: 100rpx;
			height: 100%;
		}
	}
}
</style>
